﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Order_Managemant;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Order_Managemant.Tests
{
    [TestClass()]
    public class OrderServiceTests
    {
        [TestMethod()]
        public void OrderServiceTest()
        {
            OrderService orderService = new OrderService();
            Assert.AreSame(0, orderService.orderNum);
        }

        [TestMethod()]
        public void GetNumTest()
        {
            OrderService orderService = new OrderService();
            Assert.AreSame(orderService.orderNum, orderService.GetNum());

        }

        [TestMethod()]
        public void AddOrderTest()
        {
            Order order = new Order();
            OrderService orderService = new OrderService();
            Assert.AreSame(orderService.orderList[-1], order);
        }

        [TestMethod()]
        public void DeleteOrderTest()
        {
            Order order = new Order();
            OrderService orderService = new OrderService();
            orderService.AddOrder(order);
            orderService.DeleteOrder(0);
            Assert.IsNull(orderService.orderList);
        }

        [TestMethod()]
        public void ModifyOrderTest()
        {
            OrderService orderService = new OrderService();
            Order order = new Order();
            orderService.ModifyOrder(0);
            Assert.AreNotSame(order, orderService.orderList[0]);
        }

        [TestMethod()]
        public void ExportTest()
        {
            OrderService orderService = new OrderService();
            Order order = new Order();
            orderService.AddOrder(order);
            orderService.Export();
            Order[] orders = orderService.Import();
            Assert.AreSame(orderService.orderList, orders);
        }

        [TestMethod()]
        public void ImportTest()
        {
            OrderService orderService = new OrderService();
            Order order = new Order();
            orderService.AddOrder(order);
            orderService.Export();
            Order[] orders = orderService.Import();
            Assert.AreSame(orderService.orderList, orders);
        }
    }
}